package com.hk.wms.wmsprovider9901.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RefreshScope
@RestController
public class ProviderController {
    @Value("${server.port}")
    String serverPort;
    @Value("${config.info}")
    String info;
    @RequestMapping("/provider/{id}")
    public String getServerPort(@PathVariable("id") Integer id){
        return serverPort+":"+id+":"+info;
    }
    @RequestMapping("/provider")
    public String getServerPort(){
        return serverPort+":"+info;
    }
    @GetMapping("/getStr/{id}")
    public String getStr(@PathVariable("id")int id){

        return id+":"+serverPort;

    }
    @GetMapping("/getStr2/{id}")
    public String getStr2(@PathVariable("id")int id){
        try {
            //暂停3秒线程
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return id+":"+serverPort;

    }
}
